<?php
class LoginController extends MController {

    protected $_template = 'login';

    public function indexAction(){
        __import('mandrill-box-css');
        $form = new LoginForm();
        if ($this->getRequest()->isPost()){
            if ($form->isValid($this->getRequest()->getPost())){
                $postData = $this->getRequest()->getPost();
                $return = MSession::getInstance()->login(MSession::NORMAL_AUTH, $postData['loginName'], $postData['loginPassword']);
                if ($return){
                    __redirect(__route('ml-admin'));
                }
            } else {
                $form->addError(__t('mandrill.admin.login.form.error'));
                $form->bindData($this->getRequest()->getPost());
            }
        }
        $this->render('index', array('form'=>$form));
    }
    
}
?>
